package cn.kin.service.impl;


import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Service;

import cn.kin.dao.NoticeMapper;
import cn.kin.pojo.Notice;
import cn.kin.service.NoticeService;

//通知
@Service
public class NoticeServiceImpl implements NoticeService{

	@Resource
	private NoticeMapper noticeMapper;
	
	@Override
	public List<Notice> getNoticeList(Integer pageNo,Integer pageSize) {
		// TODO Auto-generated method stub
		try {
			List<Notice> list=noticeMapper.selectByPosition((pageNo-1)*pageSize,pageSize);
			return list;
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return null;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		try {
			int result=noticeMapper.selectCountByPosition();
			return result;
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return 0;
	}
	
	@Override
	public boolean addNotice(Notice notice) {
		// TODO Auto-generated method stub
		try {
			if(noticeMapper.insertNotice(notice)>0) {
				return true;
			}
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return false;
	}
	
	@Override
	public boolean delNotice(Integer id) {
		// TODO Auto-generated method stub
		try {
			if(noticeMapper.deleteByPrimaryKey(id)>0) {
				return true;
			}
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return false;
	}
}
